﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ZCSBZPJ.Filter;
using ZP.Common;
using ZP.DTO.Common;
using ZP.DTO.gt_task_tracking;
using ZP.IBLL;

namespace ZCSBZPJ.Controllers
{
    [AuthorityFilter]
    public class GTTaskTrackingController : Controller
    {
        public Igt_task_trackingService _gt_task_trackingService { get; set; }

        public ActionResult Index()
        {
            return View();
        }

        public JsonResult GetTaskTracking(gt_task_trackingSearchDTO dto)
        {
            PageModel<gt_task_trackingResultDTO> pageList = new PageModel<gt_task_trackingResultDTO>();
            pageList = _gt_task_trackingService.GetTaskTracking(dto);
            return Json(pageList, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 保存-新增/修改
        /// </summary>
        /// <param name="dto"></param>
        /// <param name="operate">1:重置用户密码</param>
        /// <returns></returns>
        public JsonResult SaveTaskTracking(gt_task_trackingOperateDTO dto)
        {
            ResultData<string> result = new ResultData<string>();
            try
            {
                UserLoginDTO loginUser = (UserLoginDTO)Session[ZPCommon.SESSION_Login];
                dto.user_id = loginUser.id;
                result.SubmitResult = _gt_task_trackingService.SaveTaskTracking(dto);
            }
            catch (Exception e)
            {
                result.SubmitResult = false;
                result.Message = e.Message;
            }

            return Json(result);
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <returns></returns>
        public JsonResult DeleteTaskTracking(List<gt_task_trackingOperateDTO> dto)
        {
            ResultData<string> result = new ResultData<string>();
            try
            {
                UserLoginDTO loginUser = (UserLoginDTO)Session[ZPCommon.SESSION_Login];
                result.SubmitResult = _gt_task_trackingService.DeleteTaskTracking(dto, loginUser);
            }
            catch (Exception ex)
            {
                result.SubmitResult = false;
                result.Message = ex.Message;
            }
            return Json(result);
        }
    }
}